package com.mall.mall.order.vo;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

// 订单确认页所需数据

public class OrderConfirmVO {
    private List<MemberAddressVO> address;// 收货地址

    private List<OrderItemVO> items;// 所有选中的商品

    // 发票记录

    private Integer integration;// 优惠积分信息

    private BigDecimal total;// 订单总额

    private BigDecimal payPrices;// 应付价格

    @Getter@Setter
    private Map<Long, Boolean> stocks;

    @Getter@Setter
    private String orderToken;

    public List<MemberAddressVO> getAddress() {
        return address;
    }

    public void setAddress(List<MemberAddressVO> address) {
        this.address = address;
    }

    public List<OrderItemVO> getItems() {
        return items;
    }

    public void setItems(List<OrderItemVO> items) {
        this.items = items;
    }

    public Integer getIntegration() {
        return integration;
    }

    public void setIntegration(Integer integration) {
        this.integration = integration;
    }

    public BigDecimal getTotal() {
        BigDecimal sum = new BigDecimal("0");
        if (null != items){
            for (OrderItemVO item : items){
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));
                sum = sum.add(multiply);
            }
        }
        return sum;
    }

    public void setTotal(BigDecimal total) {
        this.total = total;
    }

    public BigDecimal getPayPrices() {
        return getTotal();
    }

    public void setPayPrices(BigDecimal payPrices) {
        this.payPrices = payPrices;
    }
}
